package com.zyh.controller;

import com.zyh.entity.User;
import com.zyh.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    UserService service;

    @PostMapping("/")
    public User select(@RequestBody User user){
        User userSelected = service.selectByNameAndPassword(user.getName(), user.getPassword());
        if(userSelected!=null){
//            session.setAttribute("user",userSelected);
            return userSelected;
        }
        return null;
    }
}
